package com.kkd.cloudxipet;

import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.kkd.cloudxipet.adapter.MenuAdapter;

import java.util.zip.Inflater;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    //person_menu
    String [] items = {MenuAdapter.MENU_PERSONAL_CENTER,
            MenuAdapter.MENU_CONFIGURATION,
            MenuAdapter.MENU_HISTORY,
            MenuAdapter.MENU_COLLECT};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //click person_page
        ImageView per_page = (ImageView)findViewById(R.id.person_page);
        per_page.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ArrayAdapter<String> personMenuAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, items);
                final ListView personMenuList = (ListView)findViewById(R.id.person_menu_list);
                personMenuList.setAdapter(personMenuAdapter);
                personMenuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        String item = items[position];
                        switch (item){
                            case MenuAdapter.MENU_PERSONAL_CENTER:
                                Toast.makeText(MainActivity.this,MenuAdapter.MENU_PERSONAL_CENTER,Toast.LENGTH_SHORT).show();
                                break;
                            case MenuAdapter.MENU_COLLECT:
                                Toast.makeText(MainActivity.this,MenuAdapter.MENU_COLLECT,Toast.LENGTH_SHORT).show();
                                break;
                            case MenuAdapter.MENU_CONFIGURATION:
                                Toast.makeText(MainActivity.this,MenuAdapter.MENU_CONFIGURATION,Toast.LENGTH_SHORT).show();
                                break;
                            case MenuAdapter.MENU_HISTORY:
                                Toast.makeText(MainActivity.this,MenuAdapter.MENU_HISTORY,Toast.LENGTH_SHORT).show();
                                break;
                            default:
                                break;
                        }
                    }
                });
            }
        });
    }


}
